import json
import jsonpath

book_json="""{
  "store":{
    "book":[
      {
        "category":"reference",
        "author":"Nigel Rees",
        "title":"Sayings of the Century",
        "price":8.95
      },
      {
        "category":"fiction",
        "author":"J. R. R. Tolkien",
        "title":"The Lord of the Rings",
        "isbn":"0-395-19395-8",
        "price":22.99
      }
    ],
    "bicycle":{
      "color":"red",
      "price":19.95
    }
  }
}
"""
books = json.loads(book_json)

json_expression = "$.store.bicycle.color"
result = jsonpath.jsonpath(books, json_expression)
print(result)

json_expression2 = "$.store.book[*]"
result2 = jsonpath.jsonpath(books, json_expression2)
print(result2)

json_expression3 = "$.store.book[0]"
result3 = jsonpath.jsonpath(books, json_expression3)
print(result3)

json_expression4= "$.store.book[*].title"
result4 = jsonpath.jsonpath(books, json_expression4)
print(result4)

json_expression5= "$.store.book[?(@.category=='fiction')]"
result5 = jsonpath.jsonpath(books, json_expression5)
print(result5)

json_expression6= "$.store.book[?(@.price<10)]"
result6 = jsonpath.jsonpath(books, json_expression6)
print(result6)

json_expression7= "$.store.book[?(@.isbn)]"
result7 = jsonpath.jsonpath(books, json_expression7)
print(result7)
